﻿using Gsiot.Server;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

public class VoltageMonitor
{
    public static void Main()
    {
        // ground and power for the potentiometer
        var lowPort = new OutputPort(Pins.GPIO_PIN_A0, false);
        var highPort = new OutputPort(Pins.GPIO_PIN_A2, true);

        var voltageSensor = new AnalogSensor
        {
            InputPin = Pins.GPIO_PIN_A1,
            MinValue = 0.0,
            MaxValue = 3.3
        };

        var webServer = new HttpServer
        {
            RelayDomain = "<insert your relay domain here>",
            RelaySecretKey = "<insert your secret key here>",
            RequestRouting =
            {
                {
                    "GET /voltage/actual",
                    new MeasuredVariable
                    {
                        FromSensor = voltageSensor.HandleGet
                    }.HandleRequest
                }
            }
        };

        webServer.Run();
    }
}
